import 'package:chewie/chewie.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../../resources/l10n/kq_intl.dart';
import '../../../widgets/titleBar/kq_title_bar.dart';
import 'controller.dart';

/// 视频播放页面
class VideoPlayPage extends StatelessWidget {
  const VideoPlayPage({super.key});

  @override
  Widget build(BuildContext context) {
    final controller = Get.put(VideoPlayController());
    final state = controller.state;

    return GetBuilder<VideoPlayController>(
        init: controller,
        builder: (controller) {
          return WillPopScope(
              onWillPop: () async {
                Get.back();
                return false;
              },
              child: Scaffold(
                appBar: KqHeadBar(
                  headTitle: state.title ?? KqIntl.currentResource.videoPlay,
                  back: () => Get.back(),
                ),
                body: Container(
                  color: Colors.black,
                  child: Center(
                    child: Chewie(
                      controller: controller.chewieController,
                    ),
                  ),
                ),
              ));
        });
  }
}
